#!/bin/bash -e

function info() {
echo Usage: `basename $0` 'in'
exit 2
}

while getopts  ":p:f:" opt; do
	case  $opt  in
		p) prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

log=~/.backup.log
out_prefix=${prefix:=$1}
suffix=${suffix:=`date +%m%d%H%M`}


# . $var

while true; do
    
    echo
    if test `date +%k` -eq 13; then
        echo `id -u` `date +%m%d%H%M` `pwd` `hostname` $$ `basename $0` -p$out_prefix -f$suffix $@ >> $log 2>&1
        zip -r ~/.bk/$out_prefix.$suffix.zip $@
        echo -e 'done\n' >> $log 2>&1
    fi
    
    sleep 57m
done
